home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 1996-11-07 | 85.1 KB | 3,262 lines | [ TEXT/CWIE]
// // The Gray Council MacApp Adapter // Copyright ©1996 by Trygve Isaacson. All Rights Reserved. // // MacApp adapter classes for The Gray Council core classes. // // Before using any of the Gray Council source code, read and // follow the licensing info in the accompanying documentation // or contact: // <trygve@bombaydigital.com> // <http://www.bombaydigital.com> // // Also check the web site above to make sure you have the latest version! // // The Gray Council provides a set of standard C++ classes that implement // the standard Apple Grayscale Appearance. The core classes do not // require any other code such as a particular class framework. // // This file defines a set of helper classes that derive from standard // MacApp view classes, and interface with the core Gray Council code. // There are also a couple of adorner subclasses for attaching to windows // and list boxes to get the correct background color or target border. // // Normally, to use a Gray Council MacApp class, you can simply change the // class name of the subview in your resource file or AdLib view to the // class name of the appropriate Gray Council MacApp adapter class. For // example, to use the GC pushbutton, create a normal TButton subview, // and set its class name to AGAPushButtonMA. Voila. // // A couple of the classes use the userData field of the subview to specify // additional information such as icon IDs, string resource IDs, etc. // // To statically instantiate one of these MacApp subclasses at runtime, // not via a view resource, use the class' supplied "I" method. // // Each class here that interfaces to a core AGAObject has a public // member variable called mAGAObject that points to the actual AGAObject // subclass object. Certain extended object settings (such as mixed-state // buttons, proportional and live scrolling, etc.) require you to call // the AGAObject to set it. The member variable is made public to keep // these MacApp classes as lightweight as possible; you make the call, // rather than using myriad new functions of the MacApp AGA subclasses. // // Classes defined below: // AGAPushButtonMA -- TButton subclass for AGAPushButton // AGACheckBoxMA -- TCheckBox subclass for AGACheckBox // AGARadioButtonMA -- TRadio subclass for AGARadioButton // AGAIconPushButtonMA -- AGAPushButtonMA (TButton) subclass for AGAIconPushButton // AGAIconCheckBoxMA -- AGACheckBoxMA (TCheckBox) subclass for AGAIconCheckBox // AGAIconRadioButtonMA -- AGARadioButtonMA (TRadio) subclass for AGAIconRadioButton // AGAScrollBarMA -- TScrollBar subclass for AGAScrollBar // AGAScrollerScrollBarMA -- TScrollerScrollBar subclass for AGAScrollBar // Remember the difference between TScrollBar and TScrollerScrollBar! // AGASliderMA -- TControl subclass for AGASlider // AGABackgroundAdornerMA -- TAdorner subclass that you should attach to // typical modeless windows; gives it the proper modeless gray background // AGAModalBackgroundAdornerMA -- AGABackgroundAdornerMA (TAdorner) subclass // that you should attach to modal windows (i.e., things you PoseModally); // gives it the proper modal gray background; however, for dBoxProc and // moveableDBoxProc windows, leaves window structure region white, so // you may prefer to use AGAFlatBackgroundBehaviorMA in these cases // AGAFlatBackgroundBehaviorMA -- TBehavior subclass that you should attach // to modal windows (i.e., things you PoseModally); gives it the proper // gray background, including the window structure region, but without // raised edges // AGAWhiteBackgroundAdornerMA -- TAdorner subclass you should attach to any // view that needs a white background but lives in a gray background window // (e.g., TEditText, TScroller containing grid, etc.) // AGANotchedWhiteBackgroundAdornerMA -- AGAWhiteBackgroundAdornerMA (TAdorner) // subclass that leaves a notch in the bottom right corner, such as the // notch left by a pair of scroll bars // AGABorderFrameAdornerMA -- TAdorner subclass that you can attach to any // view that needs a "3D" sunken frame around it (e.g., the same things // that need a white background adorner) // AGANotchedBorderFrameAdornerMA -- AGABorderFrameAdornerMA (TAdorner) subclass // that leaves a notch in the bottom right corner, such as the notch left by // a pair of scroll bars // AGAPopupMA -- TPopup subclass for AGAPopupMenu // AGAStaticTextMA -- TStaticText subclass for AGAStaticText // AGALittleArrowsMA -- TControl subclass for AGALittleArrows // AGADisclosureTriangleMA -- TControl subclass for AGADisclosureTriangle // AGAProgressIndicatorMA -- TControl subclass for AGAProgressIndicator // AGASeparatorMA -- TView subclass for AGASeparator // AGATargetBorderViewMA -- TTargetBorderView subclass that draws AGA-style // target border frame // AGANotchedTargetBorderViewMA -- AGATargetBorderViewMA (TTargetBorderView) subclass // that leaves a notch in the bottom right corner, such as the notch left by a // pair of scroll bars // AGATargetBorderFrameViewMA -- AGATargetBorderViewMA (TTargetBorderView) // subclass that draws a "3D" sunken frame just like an AGABorderFrameAdornerMA // in addition to the AGA-compatible TTargetBorderView. // AGATargetBorderFrameViewMA -- AGATargetBorderFrameViewMA (TTargetBorderView) // subclass that leaves a notch in the bottom right corner, such as the notch // left by a pair of scroll bars // AGAGroupBoxMA -- TCluster subclass for AGAGroupBox // AGASecondaryGroupBoxMA -- AGAClusterMA (TCluster) subclass for AGAGroupBox // with secondary box style set // AGATabPanelMA -- TControl subclass for AGATabPanel set for large tabs. // AGASmallTabPanelMA -- AGATabPanelMA (TControl) subclass for AGATabPanel // set for small tabs. // #include "GrayCouncilMA.h" OSErr InitGrayCouncilMA() { // // Register our dynamically instantiated view subclasses. // MA_REGISTER_CLASS(AGAPushButtonMA); MA_REGISTER_CLASS(AGACheckBoxMA); MA_REGISTER_CLASS(AGARadioButtonMA); MA_REGISTER_CLASS(AGAIconPushButtonMA); MA_REGISTER_CLASS(AGAIconCheckBoxMA); MA_REGISTER_CLASS(AGAIconRadioButtonMA); MA_REGISTER_CLASS(AGAScrollBarMA); MA_REGISTER_CLASS(AGAScrollerScrollBarMA); MA_REGISTER_CLASS(AGASliderMA); MA_REGISTER_CLASS(AGABackgroundAdornerMA); MA_REGISTER_CLASS(AGAModalBackgroundAdornerMA); MA_REGISTER_CLASS(AGAFlatBackgroundBehaviorMA); MA_REGISTER_CLASS(AGAPopupMA); MA_REGISTER_CLASS(AGAStaticTextMA); MA_REGISTER_CLASS(AGALittleArrowsMA); MA_REGISTER_CLASS(AGAWhiteBackgroundAdornerMA); MA_REGISTER_CLASS(AGANotchedWhiteBackgroundAdornerMA); MA_REGISTER_CLASS(AGABorderFrameAdornerMA); MA_REGISTER_CLASS(AGANotchedBorderFrameAdornerMA); MA_REGISTER_CLASS(AGADisclosureTriangleMA); MA_REGISTER_CLASS(AGAProgressIndicatorMA); MA_REGISTER_CLASS(AGASeparatorMA); MA_REGISTER_CLASS(AGATargetBorderViewMA); MA_REGISTER_CLASS(AGANotchedTargetBorderViewMA); MA_REGISTER_CLASS(AGATargetBorderFrameViewMA); MA_REGISTER_CLASS(AGANotchedTargetBorderFrameViewMA); MA_REGISTER_CLASS(AGAGroupBoxMA); MA_REGISTER_CLASS(AGASecondaryGroupBoxMA); MA_REGISTER_CLASS(AGAGroupBoxMA); MA_REGISTER_CLASS(AGASecondaryGroupBoxMA); MA_REGISTER_CLASS(AGATabPanelMA); MA_REGISTER_CLASS(AGASmallTabPanelMA); // Do Core Gray Council initialization. return InitGrayCouncil(); } static void SetAGAObjectFrame(TView* itsView, AGAObject* theAGAObject, const VRect& /*newViewFrame*/, Boolean /*redraw*/) { if (theAGAObject != NULL) { VRect viewRect(0, 0, itsView->fSize.h, itsView->fSize.v); CRect qdRect; itsView->ViewToQDRect(viewRect, qdRect); theAGAObject->SetObjectBounds(qdRect, AGAObject::kDontRedraw); } } // // AGAPushButtonMA ---------------------------------------------------- // #undef Inherited #define Inherited TButton MA_DEFINE_CLASS_M1(AGAPushButtonMA, Inherited); AGAPushButtonMA::AGAPushButtonMA() { mAGAObject = NULL; } AGAPushButtonMA::~AGAPushButtonMA() { // Delete AGA object if we successfully allocated it. if (mAGAObject != NULL) delete mAGAObject; } void AGAPushButtonMA::IAGAPushButtonMA(TView* itsSuperView, const VPoint& itsLocation, const VPoint& itsSize, SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, const CStr255& itsLabel) { this->IButton(itsSuperView, itsLocation, itsSize, itsHSizeDet, itsVSizeDet, itsLabel); this->CreateAGAObject(); } void AGAPushButtonMA::DoPostCreate(TDocument* itsDocument) { // Create and set up the AGAObject. Inherited::DoPostCreate(itsDocument); this->CreateAGAObject(); } void AGAPushButtonMA::CreateAGAObject() { // Instantiate the particular AGAObject subclass. (void) this->SetCMgrVisibility(false); VRect viewRect(0, 0, fSize.h, fSize.v); CRect bounds; CStr255 viewTitle; this->ViewToQDRect(viewRect, bounds); this->GetText(viewTitle); FailNIL(mAGAObject = new AGAPushButton(bounds, AGATextStyle(fTextStyle), viewTitle)); if (fDimmed || ! fEnabled) mAGAObject->SetEnable(AGAObject::kDisabled, AGAObject::kDontRedraw); // // We implement the default button outline by checking for the // presence of the TRRectAdorner by std ID, tossing it, and // telling the AGA button object that it is a default button. // Because the AGA default button outline is equivalent to a // 3x3 pen outline, whereas a TButton with a TRRectAdorner is // sized for a 4x4 outline, we need to inset the AGA object by // 1x1. // TAdorner* rrectAdorner = this->FindRRectAdorner(); if (rrectAdorner != NULL) { this->DeleteAdorner(rrectAdorner, kDontInvalidate); mAGAObject->SetDefault(AGAObject::kIsDefault, AGAObject::kFrameInside); mAGAObject->GetObjectBounds(bounds); ::InsetRect(bounds, 1, 1); mAGAObject->SetObjectBounds(bounds, AGAObject::kDontRedraw); } } void AGAPushButtonMA::Draw(const VRect& /*area*/) { // Let the AGAObject draw itself. if (mAGAObject != NULL) mAGAObject->DrawObject(); } void AGAPushButtonMA::SetFrame(const VRect& newFrame, Boolean invalidate) { // Let the MacApp and AGA objects update their locations. Inherited::SetFrame(newFrame, invalidate); SetAGAObjectFrame(this, mAGAObject, newFrame, invalidate); if ((mAGAObject != NULL) && mAGAObject->IsDefault()) { // As noted above in AGAPushButtonMA::CreateObject, we need to // inset the AGA object frame by 1x1 if it has a default outline. CRect bounds; mAGAObject->GetObjectBounds(bounds); ::InsetRect(bounds, 1, 1); mAGAObject->SetObjectBounds(bounds, AGAObject::kDontRedraw); } } void AGAPushButtonMA::DoMouseCommand(VPoint& theMouse, TToolboxEvent* /*event*/, CPoint /*hysteresis*/) { // Let the AGAObject track the mouse; if tracking succeeds // handle our event number. if (mAGAObject->TrackMouse(this->ViewToQDPt(theMouse))) this->HandleEvent(fEventNumber, this, NULL); } void AGAPushButtonMA::HiliteState(Boolean state, Boolean /*redraw*/) { // Let the AGAPushButton draw in the specified state. if ((mAGAObject != NULL) && this->Focus()) mAGAObject->DrawButton(state); } void AGAPushButtonMA::Hilite() { // Let the AGAPushButton draw in pressed state. if ((mAGAObject != NULL) && this->Focus()) mAGAObject->DrawButton(AGAObject::kPressed); } void AGAPushButtonMA::DimState(Boolean state, Boolean redraw) { // Set the AGAObject's enable state. fDimmed = state; if ((mAGAObject != NULL) && this->Focus()) mAGAObject->SetEnable(!state, redraw && this->IsVisible()); } void AGAPushButtonMA::Dim() { // Set the AGAObject's enable state, with immediate redraw. if (mAGAObject != NULL) mAGAObject->SetEnable(AGAObject::kDisabled, this->Focus() && this->IsVisible()); } void AGAPushButtonMA::SetEnable(Boolean state) { Inherited::SetEnable(state); // Set the AGAObject's enable state, without redraw. if (mAGAObject != NULL) mAGAObject->SetEnable(state, AGAObject::kDontRedraw); } void AGAPushButtonMA::SetText(const CStr255& itsText, Boolean redraw) { // Change the current text in TCtlMgr and in // the AGA object. Do NOT let control mgr draw. Inherited::SetText(itsText, kDontRedraw); if (mAGAObject != NULL) { Str255 textString; Boolean wantRedraw = redraw && this->Focus() && this->IsVisible(); AGA_PLstrcpy(textString, itsText); mAGAObject->SetTitle(textString, wantRedraw); } } TAdorner* AGAPushButtonMA::FindRRectAdorner() { // Return the TRRectAdorner, if any, that is attached to // this push button. TAdorner* foundAdorner = NULL; if (fAdorners != NULL) { CAdornerIterator iter(this); for (TAdorner* theAdorner = iter.FirstAdorner(); iter.More(); theAdorner = iter.NextAdorner()) { if (MA_MEMBER(theAdorner, TRRectAdorner)) foundAdorner = theAdorner; } } return foundAdorner; } // // AGACheckBoxMA ---------------------------------------------------- // #undef Inherited #define Inherited TCheckBox MA_DEFINE_CLASS_M1(AGACheckBoxMA, Inherited); AGACheckBoxMA::AGACheckBoxMA() { mAGAObject = NULL; } AGACheckBoxMA::~AGACheckBoxMA() { // Delete AGA object if we successfully allocated it. if (mAGAObject != NULL) delete mAGAObject; } void AGACheckBoxMA::IAGACheckBoxMA(TView* itsSuperView, const VPoint& itsLocation, const VPoint& itsSize, SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, const CStr255& itsLabel, Boolean isTurnedOn) { this->ICheckBox(itsSuperView, itsLocation, itsSize, itsHSizeDet, itsVSizeDet, itsLabel, isTurnedOn); this->CreateAGAObject(); } void AGACheckBoxMA::DoPostCreate(TDocument* itsDocument) { // Create and set up the AGAObject. Inherited::DoPostCreate(itsDocument); this->CreateAGAObject(); } void AGACheckBoxMA::CreateAGAObject() { // Instantiate the particular AGAObject subclass. (void) this->SetCMgrVisibility(false); VRect viewRect(0, 0, fSize.h, fSize.v); CRect bounds; CStr255 viewTitle; this->ViewToQDRect(viewRect, bounds); this->GetText(viewTitle); FailNIL(mAGAObject = new AGACheckBox(bounds, AGATextStyle(fTextStyle), viewTitle, AGAObject::kNoAutomaticState)); if (this->GetLongVal() != 0) mAGAObject->SetValue(AGACheckBox::kCheckBoxOn, AGAObject::kDontRedraw); if (fDimmed || ! fEnabled) mAGAObject->SetEnable(AGAObject::kDisabled, AGAObject::kDontRedraw); } void AGACheckBoxMA::Draw(const VRect& /*area*/) { // Let the AGAObject draw itself. if (mAGAObject != NULL) mAGAObject->DrawObject(); } void AGACheckBoxMA::SetFrame(const VRect& newFrame, Boolean invalidate) { // Let the MacApp and AGA objects update their locations. Inherited::SetFrame(newFrame, invalidate); SetAGAObjectFrame(this, mAGAObject, newFrame, invalidate); } void AGACheckBoxMA::DoMouseCommand(VPoint& theMouse, TToolboxEvent* /*event*/, CPoint /*hysteresis*/) { // Let the AGAObject track the mouse; if tracking succeeds // handle our event number. if (mAGAObject->TrackMouse(this->ViewToQDPt(theMouse))) this->HandleEvent(fEventNumber, this, NULL); } void AGACheckBoxMA::HiliteState(Boolean state, Boolean /*redraw*/) { // Let the AGACheckBox draw in the specified state. if ((mAGAObject != NULL) && this->Focus()) mAGAObject->DrawButton(state); } void AGACheckBoxMA::Hilite() { // Let the AGACheckBox draw in pressed state. if ((mAGAObject != NULL) && this->Focus()) mAGAObject->DrawButton(AGAObject::kPressed); } void AGACheckBoxMA::DimState(Boolean state, Boolean redraw) { // Set the AGAObject's enable state. fDimmed = state; if (mAGAObject != NULL) { Boolean wantRedraw = redraw && this->Focus() && this->IsVisible(); mAGAObject->SetEnable(!state, wantRedraw); } } void AGACheckBoxMA::Dim() { // Set the AGAObject's enable state, with immediate redraw. if (mAGAObject != NULL) mAGAObject->SetEnable(AGAObject::kDisabled, this->Focus() && this->IsVisible()); } void AGACheckBoxMA::SetEnable(Boolean state) { Inherited::SetEnable(state); // Set the AGAObject's enable state, without redraw. if (mAGAObject != NULL) mAGAObject->SetEnable(state, AGAObject::kDontRedraw); } void AGACheckBoxMA::SetText(const CStr255& itsText, Boolean redraw) { // Change the current text in TCtlMgr and in // the AGA object. Do NOT let control mgr draw. Inherited::SetText(itsText, kDontRedraw); if (mAGAObject != NULL) { Str255 textString; Boolean wantRedraw = redraw && this->Focus() && this->IsVisible(); AGA_PLstrcpy(textString, itsText); mAGAObject->SetTitle(textString, wantRedraw); } } Boolean AGACheckBoxMA::IsOn() { // Return true if it's on. if (mAGAObject == NULL) return Inherited::IsOn(); else return mAGAObject->GetValue() == AGACheckBox::kCheckBoxOn; } void AGACheckBoxMA::SetState(Boolean state, Boolean redraw) { // Set the state to on or off. if (mAGAObject != NULL) { Boolean wantRedraw = redraw && this->Focus() && this->IsVisible(); mAGAObject->SetValue(state, wantRedraw); } } void AGACheckBoxMA::Toggle(Boolean redraw) { // Toggle the state between on and off. if (mAGAObject != NULL) { Boolean wantRedraw = redraw && this->Focus() && this->IsVisible(); this->SetState(! this->IsOn(), wantRedraw); } } void AGACheckBoxMA::ToggleIf(Boolean matchState, Boolean redraw) { // Toggle the state if it's currently in the specified state. if (mAGAObject != NULL) if (this->IsOn() == matchState) { Boolean wantRedraw = redraw && this->Focus() && this->IsVisible(); this->SetState(! this->IsOn(), wantRedraw); } } // // AGARadioButtonMA ---------------------------------------------------- // #undef Inherited #define Inherited TRadio MA_DEFINE_CLASS_M1(AGARadioButtonMA, Inherited); AGARadioButtonMA::AGARadioButtonMA() { mAGAObject = NULL; } AGARadioButtonMA::~AGARadioButtonMA() { // Delete AGA object if we successfully allocated it. if (mAGAObject != NULL) delete mAGAObject; } void AGARadioButtonMA::IAGARadioButtonMA(TView* itsSuperView, const VPoint& itsLocation, const VPoint& itsSize, SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, const CStr255& itsLabel, Boolean isTurnedOn) { this->IRadio(itsSuperView, itsLocation, itsSize, itsHSizeDet, itsVSizeDet, itsLabel, isTurnedOn); this->CreateAGAObject(); } void AGARadioButtonMA::DoPostCreate(TDocument* itsDocument) { // Create and set up the AGAObject. Inherited::DoPostCreate(itsDocument); this->CreateAGAObject(); } void AGARadioButtonMA::CreateAGAObject() { // Instantiate the particular AGAObject subclass. (void) this->SetCMgrVisibility(false); VRect viewRect(0, 0, fSize.h, fSize.v); CRect bounds; CStr255 viewTitle; this->ViewToQDRect(viewRect, bounds); this->GetText(viewTitle); FailNIL(mAGAObject = new AGARadioButton(bounds, AGATextStyle(fTextStyle), viewTitle, kNoGroupID, kNoGroupID, AGAObject::kNoAutomaticState)); if (this->GetLongVal() != 0) mAGAObject->SetValue(AGARadioButton::kRadioButtonOn, AGAObject::kDontRedraw); if (fDimmed || ! fEnabled) mAGAObject->SetEnable(AGAObject::kDisabled, AGAObject::kDontRedraw); } void AGARadioButtonMA::Draw(const VRect& /*area*/) { // Let the AGAObject draw itself. if (mAGAObject != NULL) mAGAObject->DrawObject(); } void AGARadioButtonMA::SetFrame(const VRect& newFrame, Boolean invalidate) { // Let the MacApp and AGA objects update their locations. Inherited::SetFrame(newFrame, invalidate); SetAGAObjectFrame(this, mAGAObject, newFrame, invalidate); } void AGARadioButtonMA::DoMouseCommand(VPoint& theMouse, TToolboxEvent* /*event*/, CPoint /*hysteresis*/) { // Let the AGAObject track the mouse; if tracking succeeds // handle our event number. if (mAGAObject->TrackMouse(this->ViewToQDPt(theMouse))) this->HandleEvent(fEventNumber, this, NULL); } void AGARadioButtonMA::HiliteState(Boolean state, Boolean /*redraw*/) { // Let the AGARadioButton draw in the specified state. if ((mAGAObject != NULL) && this->Focus() && this->IsVisible()) mAGAObject->DrawButton(state); } void AGARadioButtonMA::Hilite() { // Let the AGARadioButton draw in pressed state. if ((mAGAObject != NULL) && this->Focus() && this->IsVisible()) mAGAObject->DrawButton(AGAObject::kPressed); } void AGARadioButtonMA::DimState(Boolean state, Boolean redraw) { // Set the AGAObject's enable state. fDimmed = state; if (mAGAObject != NULL) { Boolean wantRedraw = redraw && this->Focus() && this->IsVisible(); mAGAObject->SetEnable(!state, wantRedraw); } } void AGARadioButtonMA::Dim() { // Set the AGAObject's enable state, with immediate redraw. if (mAGAObject != NULL) mAGAObject->SetEnable(AGAObject::kDisabled, this->Focus() && this->IsVisible()); } void AGARadioButtonMA::SetEnable(Boolean state) { Inherited::SetEnable(state); // Set the AGAObject's enable state, without redraw. if (mAGAObject != NULL) mAGAObject->SetEnable(state, AGAObject::kDontRedraw); } void AGARadioButtonMA::SetText(const CStr255& itsText, Boolean redraw) { // Change the current text in TCtlMgr and in // the AGA object. Do NOT let control mgr draw. Inherited::SetText(itsText, kDontRedraw); if (mAGAObject != NULL) { Str255 textString; Boolean wantRedraw = redraw && this->Focus() && this->IsVisible(); AGA_PLstrcpy(textString, itsText); mAGAObject->SetTitle(textString, wantRedraw); } } Boolean AGARadioButtonMA::IsOn() { // Return true if it's on. if (mAGAObject == NULL) return Inherited::IsOn(); else return mAGAObject->GetValue() == AGARadioButton::kRadioButtonOn; } void AGARadioButtonMA::SetState(Boolean state, Boolean redraw) { // Set the state to on or off. if (mAGAObject != NULL) { Boolean wantRedraw = redraw && this->Focus() && this->IsVisible(); mAGAObject->SetValue(state, wantRedraw); } } void AGARadioButtonMA::Toggle(Boolean redraw) { // Toggle the state between on and off. if (mAGAObject != NULL) { Boolean wantRedraw = redraw && this->Focus() && this->IsVisible(); this->SetState(! this->IsOn(), wantRedraw); } } void AGARadioButtonMA::ToggleIf(Boolean matchState, Boolean redraw) { // Toggle the state if it's currently in the specified state. if (mAGAObject != NULL) if (this->IsOn() == matchState) { Boolean wantRedraw = redraw && this->Focus() && this->IsVisible(); this->SetState(! this->IsOn(), wantRedraw); } } // // AGAIconPushButtonMA ---------------------------------------------------- // #undef Inherited #define Inherited AGAPushButtonMA MA_DEFINE_CLASS_M1(AGAIconPushButtonMA, Inherited); void AGAIconPushButtonMA::IAGAIconPushButtonMA(TView* itsSuperView, const VPoint& itsLocation, const VPoint& itsSize, SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, const CStr255& itsLabel) { this->IAGAPushButtonMA(itsSuperView, itsLocation, itsSize, itsHSizeDet, itsVSizeDet, itsLabel); } void AGAIconPushButtonMA::CreateAGAObject() { // Instantiate the particular AGAObject subclass. (void) this->SetCMgrVisibility(false); VRect viewRect(0, 0, fSize.h, fSize.v); CRect bounds; this->ViewToQDRect(viewRect, bounds); ResNumber iconID = fUserArea; FailNIL(mAGAObject = new AGAIconPushButton(bounds, iconID, MIconButtonObject::kAutoFrame, MIconButtonObject::kAutoIconFamily)); if (fDimmed || ! fEnabled) mAGAObject->SetEnable(AGAObject::kDisabled, AGAObject::kDontRedraw); } // // AGAIconCheckBoxMA ---------------------------------------------------- // #undef Inherited #define Inherited AGACheckBoxMA MA_DEFINE_CLASS_M1(AGAIconCheckBoxMA, Inherited); void AGAIconCheckBoxMA::IAGAIconCheckBoxMA(TView* itsSuperView, const VPoint& itsLocation, const VPoint& itsSize, SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, const CStr255& itsLabel, Boolean isTurnedOn) { this->IAGAIconCheckBoxMA(itsSuperView, itsLocation, itsSize, itsHSizeDet, itsVSizeDet, itsLabel, isTurnedOn); } void AGAIconCheckBoxMA::CreateAGAObject() { // Instantiate the particular AGAObject subclass. (void) this->SetCMgrVisibility(false); VRect viewRect(0, 0, fSize.h, fSize.v); CRect bounds; this->ViewToQDRect(viewRect, bounds); ResNumber iconID = fUserArea; FailNIL(mAGAObject = new AGAIconCheckBox(bounds, AGAObject::kNoAutomaticState, iconID, iconID, MIconButtonObject::kAutoFrame, MIconButtonObject::kAutoIconFamily)); if (this->GetLongVal() != 0) mAGAObject->SetValue(AGACheckBox::kCheckBoxOn, AGAObject::kDontRedraw); if (fDimmed || ! fEnabled) mAGAObject->SetEnable(AGAObject::kDisabled, AGAObject::kDontRedraw); } // // AGAIconRadioButtonMA ---------------------------------------------------- // #undef Inherited #define Inherited AGARadioButtonMA MA_DEFINE_CLASS_M1(AGAIconRadioButtonMA, Inherited); void AGAIconRadioButtonMA::IAGAIconRadioButtonMA(TView* itsSuperView, const VPoint& itsLocation, const VPoint& itsSize, SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, const CStr255& itsLabel, Boolean isTurnedOn) { this->IAGARadioButtonMA(itsSuperView, itsLocation, itsSize, itsHSizeDet, itsVSizeDet, itsLabel, isTurnedOn); } void AGAIconRadioButtonMA::CreateAGAObject() { // Instantiate the particular AGAObject subclass. (void) this->SetCMgrVisibility(false); VRect viewRect(0, 0, fSize.h, fSize.v); CRect bounds; this->ViewToQDRect(viewRect, bounds); ResNumber iconID = fUserArea; FailNIL(mAGAObject = new AGAIconRadioButton(bounds, kNoGroupID, kNoGroupID, AGAObject::kNoAutomaticState, iconID, iconID, MIconButtonObject::kAutoFrame, MIconButtonObject::kAutoIconFamily)); if (this->GetLongVal() != 0) mAGAObject->SetValue(AGARadioButton::kRadioButtonOn, AGAObject::kDontRedraw); if (fDimmed || ! fEnabled) mAGAObject->SetEnable(AGAObject::kDisabled, AGAObject::kDontRedraw); } // // AGAScrollBarMA ---------------------------------------------------- // #undef Inherited #define Inherited TScrollBar MA_DEFINE_CLASS_M1(AGAScrollBarMA, Inherited); AGAScrollBarMA::AGAScrollBarMA() { mNotificationRoutine = NULL; mUserData = 0; mAGAObject = NULL; } AGAScrollBarMA::~AGAScrollBarMA() { // Delete AGA object if we successfully allocated it. if (mAGAObject != NULL) delete mAGAObject; } void AGAScrollBarMA::IAGAScrollBarMA(TView* itsSuperView, const VPoint& itsLocation, const VPoint& itsSize, SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, VHSelect itsDirection, long itsVal, long itsMin, long itsMax) { this->IScrollBar(itsSuperView, itsLocation, itsSize, itsHSizeDet, itsVSizeDet, itsDirection, itsVal, itsMin, itsMax); this->CreateAGAObject(); } void AGAScrollBarMA::InstallNotificationRoutine(AGANotifyMAPtr notificationRoutine, void* userData) { // Save the notification routine fn pointer and user data // for notification handling. mNotificationRoutine = notificationRoutine; mUserData = userData; } void AGAScrollBarMA::HandleNotification(SInt32 dataValue) { // Update the scrollbar value, call the installed notification // function, and propagate our event number. this->SetLongVal(dataValue, kDontRedraw); if (mNotificationRoutine != NULL) (*mNotificationRoutine)(this, dataValue, mUserData); this->HandleEvent(fEventNumber, this, NULL); (void) this->Focus(); // HandleEvent may have caused another view to draw } void AGAScrollBarMA::DoPostCreate(TDocument* itsDocument) { // Create and set up the AGAObject. Inherited::DoPostCreate(itsDocument); this->CreateAGAObject(); } void AGAScrollBarMA::CreateAGAObject() { // Instantiate the particular AGAObject subclass. (void) this->SetCMgrVisibility(false); VRect viewRect(0, 0, fSize.h, fSize.v); CRect bounds; this->ViewToQDRect(viewRect, bounds); FailNIL(mAGAObject = new AGAScrollBar(bounds, this->GetLongMin(), this->GetLongMax(), this->GetLongVal())); mAGAObject->InstallNotificationRoutine(AGAScrollBarMA::RealAGANotifier, this); if (fDimmed || ! fEnabled) mAGAObject->SetEnable(AGAObject::kDisabled, AGAObject::kDontRedraw); } void AGAScrollBarMA::Draw(const VRect& /*area*/) { // Let the AGAObject draw itself. if (mAGAObject != NULL) mAGAObject->DrawObject(); } void AGAScrollBarMA::SetFrame(const VRect& newFrame, Boolean invalidate) { // Let the MacApp and AGA objects update their locations. Inherited::SetFrame(newFrame, invalidate); SetAGAObjectFrame(this, mAGAObject, newFrame, invalidate); } void AGAScrollBarMA::SetLongVal(VCoordinate itsVal, Boolean redraw) { // Catch all value changes here and synchronize the // AGAScrollBar accordingly. Inherited::SetLongVal(itsVal, kDontRedraw); if (mAGAObject != NULL) { Boolean wantRedraw = redraw && this->Focus() && this->IsVisible(); mAGAObject->SetValue(itsVal, wantRedraw); } } void AGAScrollBarMA::DoMouseCommand(VPoint& theMouse, TToolboxEvent* /*event*/, CPoint /*hysteresis*/) { // Let the AGAObject track the mouse. Don't call HandleEvent; // it has already been handled through HandleNotification. (void) mAGAObject->TrackMouse(this->ViewToQDPt(theMouse)); } void AGAScrollBarMA::HiliteState(Boolean /*state*/, Boolean /*redraw*/) { // Suppress Control Manager scroll bar drawing. } void AGAScrollBarMA::Hilite() { // Suppress Control Manager scroll bar drawing. } void AGAScrollBarMA::DimState(Boolean state, Boolean redraw) { // Set the AGAObject's enable state. fDimmed = state; if (mAGAObject != NULL) { Boolean wantRedraw = redraw && this->Focus() && this->IsVisible(); mAGAObject->SetEnable(!state, wantRedraw); } } void AGAScrollBarMA::Dim() { // Set the AGAObject's enable state, with immediate redraw. if (mAGAObject != NULL) mAGAObject->SetEnable(AGAObject::kDisabled, this->Focus() && this->IsVisible()); } void AGAScrollBarMA::SetEnable(Boolean state) { Inherited::SetEnable(state); // Set the AGAObject's enable state, without redraw. if (mAGAObject != NULL) mAGAObject->SetEnable(state, AGAObject::kDontRedraw); } void AGAScrollBarMA::Activate(Boolean entering) { // Set the AGAScrollBar's activated state. if (mAGAObject != NULL) mAGAObject->Activate(entering, this->Focus() && this->IsVisible()); } void AGAScrollBarMA::SetLongMax(VCoordinate itsMax, Boolean redraw) { // Set the AGAScrollBar's limit. Inherited::SetLongMax(itsMax, kDontRedraw); if (mAGAObject != NULL) { SInt32 itsMin; SInt32 itsMax; Boolean wantRedraw = redraw && this->Focus() && this->IsVisible(); mAGAObject->GetRange(&itsMin, &itsMax); mAGAObject->SetRange(itsMin, this->GetLongMax(), wantRedraw); } } void AGAScrollBarMA::RealAGANotifier(AGATrackingIndicator* /*theIndicator*/, SInt32 dataValue, void* userData) { // This is a static function. Cast the user data to get // the AGAScrollBarMA object, have it handle the notification. ((AGAScrollBarMA*) userData)->HandleNotification(dataValue); } // // AGAScrollerScrollBarMA ---------------------------------------------------- // #undef Inherited #define Inherited TScrollerScrollBar MA_DEFINE_CLASS_M1(AGAScrollerScrollBarMA, Inherited); AGAScrollerScrollBarMA::AGAScrollerScrollBarMA() { mNotificationRoutine = NULL; mUserData = 0; mAGAObject = NULL; } AGAScrollerScrollBarMA::~AGAScrollerScrollBarMA() { // Delete AGA object if we successfully allocated it. if (mAGAObject != NULL) delete mAGAObject; } void AGAScrollerScrollBarMA::IAGAScrollerScrollBarMA(TView* itsSuperView, const VPoint& itsLocation, const VPoint& itsSize, SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, VHSelect itsDirection, long itsMax, TScroller* itsScroller) { this->IScrollerScrollBar(itsSuperView, itsLocation, itsSize, itsHSizeDet, itsVSizeDet, itsDirection, itsMax, itsScroller); this->CreateAGAObject(); } void AGAScrollerScrollBarMA::InstallNotificationRoutine(AGANotifyMAPtr notificationRoutine, void* userData) { // Save the notification routine fn pointer and user data // for notification handling. mNotificationRoutine = notificationRoutine; mUserData = userData; } void AGAScrollerScrollBarMA::HandleNotification(SInt32 dataValue) { // Scroll our scrollers and call the installed notification // function. CObjectIterator iter(fScrollers); for (TScroller* aScroller = (TScroller*) iter.FirstObject(); iter.More(); aScroller = (TScroller*) iter.NextObject()) (void) aScroller->ScrollRelative(fDirection, dataValue); if (mNotificationRoutine != NULL) (*mNotificationRoutine)(this, dataValue, mUserData); (void) this->Focus(); } void AGAScrollerScrollBarMA::DoPostCreate(TDocument* itsDocument) { // Create and set up the AGAObject. Inherited::DoPostCreate(itsDocument); this->CreateAGAObject(); } void AGAScrollerScrollBarMA::CreateAGAObject() { // Instantiate the particular AGAObject subclass. (void) this->SetCMgrVisibility(false); VRect viewRect(0, 0, fSize.h, fSize.v); CRect bounds; this->ViewToQDRect(viewRect, bounds); FailNIL(mAGAObject = new AGAScrollBar(bounds, this->GetLongMin(), this->GetLongMax(), this->GetLongVal())); mAGAObject->InstallNotificationRoutine(AGAScrollerScrollBarMA::RealAGANotifier, this); if (fDimmed || ! fEnabled) mAGAObject->SetEnable(AGAObject::kDisabled, AGAObject::kDontRedraw); this->UpdateScrollAmounts(); } void AGAScrollerScrollBarMA::Draw(const VRect& /*area*/) { // Let the AGAObject draw itself. if (mAGAObject != NULL) mAGAObject->DrawObject(); } void AGAScrollerScrollBarMA::SetFrame(const VRect& newFrame, Boolean invalidate) { // Let the MacApp stuff relocate and recalculate, // then resynchronize the AGAScrollBar to the scrollers. Inherited::SetFrame(newFrame, invalidate); this->UpdateScrollAmounts(); SetAGAObjectFrame(this, mAGAObject, newFrame, invalidate); } void AGAScrollerScrollBarMA::AttachScroller(TScroller* itsScroller) { // Synchronize the AGAScrollBar to the supplied scroller. Inherited::AttachScroller(itsScroller); this->UpdateScrollAmounts(); } void AGAScrollerScrollBarMA::SetLongVal(VCoordinate itsVal, Boolean redraw) { // Catch all value changes here and synchronize the // AGAScrollBar accordingly. Inherited::SetLongVal(itsVal, kDontRedraw); if (mAGAObject != NULL) { Boolean wantRedraw = redraw && this->Focus() && this->IsVisible(); mAGAObject->SetValue(itsVal, wantRedraw); } } void AGAScrollerScrollBarMA::DoMouseCommand(VPoint& theMouse, TToolboxEvent* /*event*/, CPoint /*hysteresis*/) { // Let the AGAObject track the mouse. Don't call HandleEvent; // it has already been handled through HandleNotification. (void) mAGAObject->TrackMouse(this->ViewToQDPt(theMouse)); } void AGAScrollerScrollBarMA::HiliteState(Boolean /*state*/, Boolean /*redraw*/) { // Suppress Control Manager scroll bar drawing. } void AGAScrollerScrollBarMA::Hilite() { // Suppress Control Manager scroll bar drawing. } void AGAScrollerScrollBarMA::DimState(Boolean state, Boolean redraw) { // Set the AGAObject's enable state. fDimmed = state; if (mAGAObject != NULL) { Boolean wantRedraw = redraw && this->Focus() && this->IsVisible(); mAGAObject->SetEnable(!state, wantRedraw); } } void AGAScrollerScrollBarMA::Dim() { // Set the AGAObject's enable state, with immediate redraw. if (mAGAObject != NULL) mAGAObject->SetEnable(AGAObject::kDisabled, this->Focus() && this->IsVisible()); } void AGAScrollerScrollBarMA::SetEnable(Boolean state) { Inherited::SetEnable(state); // Set the AGAObject's enable state, without redraw. if (mAGAObject != NULL) mAGAObject->SetEnable(state, AGAObject::kDontRedraw); } void AGAScrollerScrollBarMA::Activate(Boolean entering) { // Set the AGAScrollBar's activated state. if (mAGAObject != NULL) mAGAObject->Activate(entering, this->Focus()); } void AGAScrollerScrollBarMA::SetLongMax(VCoordinate itsMax, Boolean redraw) { // Set the AGAScrollBar's limit. Inherited::SetLongMax(itsMax, kDontRedraw); if (mAGAObject != NULL) { SInt32 itsMin; SInt32 itsMax; Boolean wantRedraw = redraw && this->Focus() && this->IsVisible(); mAGAObject->GetRange(&itsMin, &itsMax); mAGAObject->SetRange(itsMin, this->GetLongMax(), wantRedraw); this->UpdateScrollAmounts(); } } void AGAScrollerScrollBarMA::UpdateScrollAmounts() { // Synchronize the AGAScrollBar to reflect the scroller state. if ((mAGAObject != NULL) && (fScrollers->GetSize() > 0)) { TScroller* aScroller = (TScroller*) fScrollers->At(1); VCoordinate maxTranslation = aScroller->fMaxTranslation[fDirection]; VCoordinate viewSize = aScroller->fSize[fDirection]; VCoordinate singleStepSize = aScroller->fScrollUnit[fDirection]; VCoordinate pageStepSize = Max(0, viewSize - singleStepSize); VCoordinate pageSize = maxTranslation * (((float) (Max(0, viewSize - singleStepSize))) / ((float) (viewSize + maxTranslation))); (void) this->Focus(); mAGAObject->SetRange(0, maxTranslation, kDontRedraw); mAGAObject->SetPageSize(pageSize, kRedraw); mAGAObject->SetStepSizes(singleStepSize, pageStepSize); } } void AGAScrollerScrollBarMA::RealAGANotifier(AGATrackingIndicator* /*theIndicator*/, SInt32 dataValue, void* userData) { // This is a static function. Cast the user data to get // the AGAScrollerScrollBarMA object, have it handle the notification. ((AGAScrollerScrollBarMA*) userData)->HandleNotification(dataValue); } // // AGASliderMA ---------------------------------------------------- // #undef Inherited #define Inherited TControl MA_DEFINE_CLASS_M1(AGASliderMA, Inherited); AGASliderMA::AGASliderMA() { mNotificationRoutine = NULL; mUserData = 0; mAGAObject = NULL; } AGASliderMA::~AGASliderMA() { // Delete AGA object if we successfully allocated it. if (mAGAObject != NULL) delete mAGAObject; } void AGASliderMA::IAGASliderMA(TView* itsSuperView, const VPoint& itsLocation, const VPoint& itsSize, SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, const TextStyle& itsTextStyle) { this->IControl(itsSuperView, itsLocation, itsSize, itsHSizeDet, itsVSizeDet, itsTextStyle); this->CreateAGAObject(); } void AGASliderMA::InstallNotificationRoutine(AGANotifyMAPtr notificationRoutine, void* userData) { // Save the notification routine fn pointer and user data // for notification handling. mNotificationRoutine = notificationRoutine; mUserData = userData; } void AGASliderMA::HandleNotification(SInt32 dataValue) { // Update the control value, call the installed notification // function, and propagate our event number. //this->SetLongVal(dataValue, kDontRedraw); TControl has no implicit value if (mNotificationRoutine != NULL) (*mNotificationRoutine)(this, dataValue, mUserData); this->HandleEvent(fEventNumber, this, NULL); (void) this->Focus(); // HandleEvent may have caused another view to draw } void AGASliderMA::DoPostCreate(TDocument* itsDocument) { // Create and set up the AGAObject. Inherited::DoPostCreate(itsDocument); this->CreateAGAObject(); } void AGASliderMA::CreateAGAObject() { // Instantiate the particular AGAObject subclass. VRect viewRect(0, 0, fSize.h, fSize.v); CRect bounds; this->ViewToQDRect(viewRect, bounds); FailNIL(mAGAObject = new AGASlider(bounds, 0, 1, 0, AGATextStyle(fTextStyle), fUserArea)); mAGAObject->InstallNotificationRoutine(AGASliderMA::RealAGANotifier, this); if (fDimmed || ! fEnabled) mAGAObject->SetEnable(AGAObject::kDisabled, AGAObject::kDontRedraw); // Slider has to erase when drawing, so make sure that // it doesn't assume we're on a gray background. this->Focus(); InstallAGABackgroundColors(mAGAObject, kInstallOnlyIfCustom); } void AGASliderMA::Draw(const VRect& /*area*/) { // Let the AGAObject draw itself. if (mAGAObject != NULL) mAGAObject->DrawObject(); } void AGASliderMA::SetFrame(const VRect& newFrame, Boolean invalidate) { // Let the MacApp and AGA objects update their locations. Inherited::SetFrame(newFrame, invalidate); SetAGAObjectFrame(this, mAGAObject, newFrame, invalidate); } void AGASliderMA::DoMouseCommand(VPoint& theMouse, TToolboxEvent* /*event*/, CPoint /*hysteresis*/) { // Let the AGAObject track the mouse; if tracking succeeds // handle our event number. if (mAGAObject->TrackMouse(this->ViewToQDPt(theMouse))) this->HandleEvent(fEventNumber, this, NULL); } void AGASliderMA::DimState(Boolean state, Boolean redraw) { // Set the AGAObject's enable state. fDimmed = state; if (mAGAObject != NULL) { Boolean wantRedraw = redraw && this->Focus() && this->IsVisible(); mAGAObject->SetEnable(!state, wantRedraw); } } void AGASliderMA::Dim() { // Set the AGAObject's enable state, with immediate redraw. if (mAGAObject != NULL) mAGAObject->SetEnable(AGAObject::kDisabled, this->Focus() && this->IsVisible()); } void AGASliderMA::SetEnable(Boolean state) { Inherited::SetEnable(state); // Set the AGAObject's enable state, without redraw. if (mAGAObject != NULL) mAGAObject->SetEnable(state, AGAObject::kDontRedraw); } void AGASliderMA::RealAGANotifier(AGATrackingIndicator* /*theIndicator*/, SInt32 dataValue, void* userData) { // This is a static function. Cast the user data to get // the AGASliderMA object, have it handle the notification. ((AGASliderMA*) userData)->HandleNotification(dataValue); } // // AGABackgroundAdornerMA ---------------------------------------------------- // #undef Inherited #define Inherited TAdorner MA_DEFINE_CLASS_M1(AGABackgroundAdornerMA, Inherited); AGABackgroundAdornerMA::AGABackgroundAdornerMA() { mBackgroundKind = kRaisedModelessBackground; } void AGABackgroundAdornerMA::DoHighlightSelection(TView* itsView, const VRect& area, HLState /*fromHL*/, HLState toHL) { // Draw in the specified active/inactive state. this->DrawBackground(itsView, area, false, (toHL == hlOn)); } void AGABackgroundAdornerMA::Draw(TView* itsView, const VRect& area) { // Draw in active state. this->DrawBackground(itsView, area, true, itsView->IsActive()); } void AGABackgroundAdornerMA::ViewChangedFrame(TView* itsView, const VRect& oldFrame, const VRect& newFrame, Boolean /*invalidate*/) { // Make sure we invalidate the edges that will need to be // redrawn with the background edge pixel color. // Note that oldFrame & newFrame are in global coordinates. VRect rectToInvalidate; VPoint sizeDelta(newFrame.GetLength(hSel) - oldFrame.GetLength(hSel), newFrame.GetLength(vSel) - oldFrame.GetLength(vSel)); if (sizeDelta.h != 0) { if (sizeDelta.h > 0) rectToInvalidate = oldFrame; else // sizeDelta.h < 0 rectToInvalidate = newFrame; rectToInvalidate.left = rectToInvalidate.right - 1; itsView->SuperToLocalVRect(rectToInvalidate); itsView->InvalidateVRect(rectToInvalidate); } if (sizeDelta.v != 0) { if (sizeDelta.v > 0) rectToInvalidate = oldFrame; else // sizeDelta.v < 0 rectToInvalidate = newFrame; rectToInvalidate.top = rectToInvalidate.bottom - 1; itsView->SuperToLocalVRect(rectToInvalidate); itsView->InvalidateVRect(rectToInvalidate); } if (this->HasGrowBox(itsView)) { rectToInvalidate = oldFrame; rectToInvalidate.left = rectToInvalidate.right - 16; rectToInvalidate.top = rectToInvalidate.bottom - 16; itsView->SuperToLocalVRect(rectToInvalidate); itsView->InvalidateVRect(rectToInvalidate); rectToInvalidate = newFrame; rectToInvalidate.left = rectToInvalidate.right - 16; rectToInvalidate.top = rectToInvalidate.bottom - 16; itsView->SuperToLocalVRect(rectToInvalidate); itsView->InvalidateVRect(rectToInvalidate); } } void AGABackgroundAdornerMA::AddedToView(TView* itsView) { // Set the current bg color of the view's port so that any of our // AGA adapter views that get instantiated will pick it up. if (itsView->Focus()) ::RGBBackColor(&gAGARamp[r2]); } void AGABackgroundAdornerMA::DrawBackground(TView* itsView, const VRect& /*area*/, Boolean fill, Boolean active) { CRect qdArea; itsView->GetQDExtent(qdArea); AGABackgroundPaint(qdArea, fill, mBackgroundKind, active, this->HasGrowBox(itsView)); } Boolean AGABackgroundAdornerMA::HasGrowBox(TView* itsView) { if (MA_MEMBER(itsView, TWindow)) return ((TWindow*) itsView)->fIsResizable; else return false; } // // AGAModalBackgroundAdornerMA ---------------------------------------------------- // #undef Inherited #define Inherited AGABackgroundAdornerMA MA_DEFINE_CLASS_M1(AGAModalBackgroundAdornerMA, Inherited); AGAModalBackgroundAdornerMA::AGAModalBackgroundAdornerMA() { mBackgroundKind = kRaisedModalBackground; } // // AGAFlatBackgroundBehaviorMA ---------------------------------------------------- // #undef Inherited #define Inherited TBehavior MA_DEFINE_CLASS_M1(AGAFlatBackgroundBehaviorMA, Inherited); AGAFlatBackgroundBehaviorMA::AGAFlatBackgroundBehaviorMA() { } AGAFlatBackgroundBehaviorMA::~AGAFlatBackgroundBehaviorMA() { } void AGAFlatBackgroundBehaviorMA::DoPostCreate(TDocument* itsDocument) { // Install the background color. Inherited::DoPostCreate(itsDocument); TWindow* theWindow = ((TView*) fOwner)->GetWindow(); FailOSErr(AGAInstallGrayWCTB(theWindow->fWMgrWindow)); // Set the current bg color of the view's port so that any of our // AGA adapter views that get instantiated will pick it up. if (theWindow->Focus()) ::RGBBackColor(&gAGARamp[r2]); } // // AGAWhiteBackgroundAdornerMA ---------------------------------------------------- // #undef Inherited #define Inherited TAdorner MA_DEFINE_CLASS_M1(AGAWhiteBackgroundAdornerMA, Inherited); void AGAWhiteBackgroundAdornerMA::Draw(TView* itsView, const VRect& /*area*/) { // Draw the background in white, inset to avoid the border // frame pixels. CRect qdArea; itsView->GetQDExtent(qdArea); ::RGBForeColor(&gAGARamp[rW]); ::RGBBackColor(&gAGARamp[rW]); ::InsetRect(qdArea, 2, 2); ::PaintRect(qdArea); ::RGBForeColor(&gAGARamp[rB]); } // // AGANotchedWhiteBackgroundAdornerMA ---------------------------------------------------- // #undef Inherited #define Inherited TAdorner MA_DEFINE_CLASS_M1(AGANotchedWhiteBackgroundAdornerMA, Inherited); void AGANotchedWhiteBackgroundAdornerMA::Draw(TView* itsView, const VRect& /*area*/) { // Draw the background in white, inset to avoid the border // frame pixels. CRect qdArea; itsView->GetQDExtent(qdArea); ::RGBForeColor(&gAGARamp[rW]); ::InsetRect(qdArea, 2, 2); qdArea.right -= 15; ::PaintRect(qdArea); qdArea.right += 15; qdArea.bottom -= 15; ::PaintRect(qdArea); ::RGBForeColor(&gAGARamp[rB]); } // // AGABorderFrameAdornerMA ---------------------------------------------------- // #undef Inherited #define Inherited TAdorner MA_DEFINE_CLASS_M1(AGABorderFrameAdornerMA, Inherited); void AGABorderFrameAdornerMA::Draw(TView* itsView, const VRect& /*area*/) { // Draw the frame with shading outside. CRect qdArea; itsView->GetQDExtent(qdArea); AGADrawBorderFrame(qdArea, itsView->IsEnabled(), false /*isNotched*/, true /*drawFrame*/, &gAGARamp[r2]); ::RGBForeColor(&gAGARamp[rB]); ::RGBBackColor(&gAGARamp[rW]); } // // AGANotchedBorderFrameAdornerMA ---------------------------------------------------- // #undef Inherited #define Inherited TAdorner MA_DEFINE_CLASS_M1(AGANotchedBorderFrameAdornerMA, Inherited); void AGANotchedBorderFrameAdornerMA::Draw(TView* itsView, const VRect& /*area*/) { // Draw the frame with shading outside. CRect qdArea; itsView->GetQDExtent(qdArea); AGADrawBorderFrame(qdArea, itsView->IsEnabled(), true /*isNotched*/, true /*drawFrame*/, &gAGARamp[r2]); ::RGBForeColor(&gAGARamp[rB]); ::RGBBackColor(&gAGARamp[rW]); } // // AGAPopupMA ---------------------------------------------------- // #undef Inherited #define Inherited TPopup MA_DEFINE_CLASS_M1(AGAPopupMA, Inherited); AGAPopupMA::AGAPopupMA() { mAGAObject = NULL; } AGAPopupMA::~AGAPopupMA() { // Delete AGA object if we successfully allocated it. if (mAGAObject != NULL) delete mAGAObject; } void AGAPopupMA::IAGAPopupMA(TView* itsSuperView, const VPoint& itsLocation, const VPoint& itsSize, SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, short itsMenuID, short itsCurrentItem, short itsItemOffset, short itsStrListID, short itsIndex, short itsStyle, short itsJust, Boolean useAddResMenu, ResType useAddResMenuResType, const TextStyle& itsTextStyle) { this->IPopup(itsSuperView, itsLocation, itsSize, itsHSizeDet, itsVSizeDet, itsMenuID, itsCurrentItem, itsItemOffset, itsStrListID, itsIndex, itsStyle, itsJust, useAddResMenu, useAddResMenuResType, itsTextStyle); this->CreateAGAObject(); } void AGAPopupMA::DoPostCreate(TDocument* itsDocument) { // Create and set up the AGAObject. Inherited::DoPostCreate(itsDocument); this->CreateAGAObject(); } void AGAPopupMA::CreateAGAObject() { // Instantiate the particular AGAObject subclass. (void) this->SetCMgrVisibility(false); AGAPopupMenu::WidthAdjust widthAdjust; VRect viewRect(0, 0, fSize.h, fSize.v); CRect bounds; CStr255 viewTitle; AGATextStyle titleStyle(fTextStyle); AGATextStyle textStyle(fTextStyle); titleStyle.mFontStyle = fTitleStyle; textStyle.mFontStyle = normal; // the actual popup can't have a style, even though AdLib allows it to be set this->ViewToQDRect(viewRect, bounds); this->GetText(viewTitle); if (fSizeDeterminer[hSel] == sizeFixed) widthAdjust = AGAPopupMenu::kFixedWidth; else widthAdjust = AGAPopupMenu::kSystemMDEFAdjustment; FailNIL(mAGAObject = new AGAPopupMenu(bounds, fItemOffset, viewTitle, fTitleJust, titleStyle, textStyle, widthAdjust, this->GetMenuRef(), AGAPopupMenu::kDontDispose)); mAGAObject->SetCurrentItemNo((SInt16) this->GetLongVal(), AGAObject::kDontRedraw); if (fDimmed || ! fEnabled) mAGAObject->SetEnable(AGAObject::kDisabled, AGAObject::kDontRedraw); } void AGAPopupMA::Draw(const VRect& /*area*/) { // Let the AGAObject draw itself. if (mAGAObject != NULL) mAGAObject->DrawObject(); } void AGAPopupMA::SetFrame(const VRect& newFrame, Boolean invalidate) { // Let the MacApp and AGA objects update their locations. Inherited::SetFrame(newFrame, invalidate); SetAGAObjectFrame(this, mAGAObject, newFrame, invalidate); } void AGAPopupMA::DoMouseCommand(VPoint& theMouse, TToolboxEvent* /*event*/, CPoint /*hysteresis*/) { // Let the AGAObject track the mouse; if tracking succeeds // handle our event number. if (mAGAObject->TrackMouse(this->ViewToQDPt(theMouse))) this->HandleEvent(fEventNumber, this, NULL); } void AGAPopupMA::DimState(Boolean state, Boolean redraw) { // Set the AGAObject's enable state. fDimmed = state; if (mAGAObject != NULL) { Boolean wantRedraw = redraw && this->Focus() && this->IsVisible(); mAGAObject->SetEnable(!state, wantRedraw); } } void AGAPopupMA::Dim() { // Set the AGAObject's enable state, with immediate redraw. if (mAGAObject != NULL) mAGAObject->SetEnable(AGAObject::kDisabled, this->Focus() && this->IsVisible()); } void AGAPopupMA::SetEnable(Boolean state) { Inherited::SetEnable(state); // Set the AGAObject's enable state, without redraw. if (mAGAObject != NULL) mAGAObject->SetEnable(state, AGAObject::kDontRedraw); } void AGAPopupMA::AttachMenuRef(MenuRef itsMenuRef) { // // Since TPopup owns the menu, it will do the disposal. // Inherited::AttachMenuRef(itsMenuRef); if (mAGAObject != NULL) mAGAObject->SetMenuRef(itsMenuRef, AGAPopupMenu::kDontDispose); } void AGAPopupMA::SetText(const CStr255& title, Boolean redraw) { // Install the new popup title (label). Inherited::SetText(title, redraw); if (mAGAObject != NULL) { CStr255 newTitle = title; mAGAObject->SetTitle(newTitle, redraw && this->Focus() && this->IsVisible()); } } void AGAPopupMA::SetLongVal(VCoordinate itsVal, Boolean redraw) { // Catch all value changes here and synchronize the // AGAPopupMenu accordingly. if (mAGAObject != NULL) mAGAObject->SetCurrentItemNo((SInt16) itsVal, redraw && this->Focus() && this->IsVisible()); else Inherited::SetLongVal(itsVal, redraw); } SInt16 AGAPopupMA::GetVal() { // Return the currently selected item number. if (mAGAObject != NULL) return mAGAObject->GetCurrentItemNo(); else return Inherited::GetVal(); } // // AGAStaticTextMA ---------------------------------------------------- // #undef Inherited #define Inherited TStaticText MA_DEFINE_CLASS_M1(AGAStaticTextMA, Inherited); AGAStaticTextMA::AGAStaticTextMA() { mAGAObject = NULL; } AGAStaticTextMA::~AGAStaticTextMA() { // Delete AGA object if we successfully allocated it. if (mAGAObject != NULL) delete mAGAObject; } void AGAStaticTextMA::IAGAStaticTextMA(TView* itsSuperView, const VPoint& itsLocation, const VPoint& itsSize, SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, ResNumber itsRsrcID, short itsIndex) { this->IStaticText(itsSuperView, itsLocation, itsSize, itsHSizeDet, itsVSizeDet, itsRsrcID, itsIndex); this->CreateAGAObject(); } void AGAStaticTextMA::DoPostCreate(TDocument* itsDocument) { // Create and set up the AGAObject. Inherited::DoPostCreate(itsDocument); VRect viewRect(0, 0, fSize.h, fSize.v); CRect qdRect; this->ViewToQDRect(viewRect, qdRect); this->CreateAGAObject(); // A static text paints its background, so make sure that // it doesn't assume we're on a gray background. this->Focus(); InstallAGABackgroundColors(mAGAObject, kInstallOnlyIfCustom); } void AGAStaticTextMA::CreateAGAObject() { // Instantiate the particular AGAObject subclass. VRect viewRect(0, 0, fSize.h, fSize.v); CRect bounds; CStr255 viewTitle; this->ViewToQDRect(viewRect, bounds); this->GetText(viewTitle); FailNIL(mAGAObject = new AGAStaticText(bounds, AGATextStyle(fTextStyle), fJust, viewTitle)); // Note that unlike other controls, for static text, we allow // "disabled" text to draw normal. This is because static text // views typically are "disabled" but not "dimmed". if (fDimmed) mAGAObject->SetEnable(AGAObject::kDisabled, AGAObject::kDontRedraw); } void AGAStaticTextMA::DimState(Boolean state, Boolean redraw) { // Set the AGAObject's enable state. fDimmed = state; if (mAGAObject != NULL) { Boolean wantRedraw = redraw && this->Focus() && this->IsVisible(); mAGAObject->SetEnable(!state, wantRedraw); } } void AGAStaticTextMA::Dim() { // Set the AGAObject's enable state, with immediate redraw. if (mAGAObject != NULL) mAGAObject->SetEnable(AGAObject::kDisabled, this->Focus() && this->IsVisible()); } void AGAStaticTextMA::SetText(const CStr255& theText, Boolean redraw) { // Change the current text in TStaticText and in // the AGAStaticText. Do NOT let TStaticText redraw, // because it erases to white. Inherited::SetText(theText, kDontRedraw); if (mAGAObject != NULL) { Str255 textString; Boolean wantRedraw = redraw && this->Focus() && this->IsVisible(); AGA_PLstrcpy(textString, theText); mAGAObject->SetTitle(textString, wantRedraw); } } void AGAStaticTextMA::Draw(const VRect& /*area*/) { // Let the AGAObject draw itself. if (mAGAObject != NULL) mAGAObject->DrawObject(); } void AGAStaticTextMA::SetFrame(const VRect& newFrame, Boolean invalidate) { // Let the MacApp and AGA objects update their locations. Inherited::SetFrame(newFrame, invalidate); SetAGAObjectFrame(this, mAGAObject, newFrame, invalidate); } // // AGALittleArrowsMA ---------------------------------------------------- // #undef Inherited #define Inherited TControl MA_DEFINE_CLASS_M1(AGALittleArrowsMA, Inherited); AGALittleArrowsMA::AGALittleArrowsMA() { mNotificationRoutine = NULL; mUserData = 0; mAGAObject = NULL; mLinkedNumberText = NULL; } AGALittleArrowsMA::~AGALittleArrowsMA() { // Delete AGA object if we successfully allocated it. if (mAGAObject != NULL) delete mAGAObject; } void AGALittleArrowsMA::IAGALittleArrowsMA(TView* itsSuperView, const VPoint& itsLocation, const VPoint& itsSize, SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, const TextStyle& itsTextStyle) { this->IControl(itsSuperView, itsLocation, itsSize, itsHSizeDet, itsVSizeDet, itsTextStyle); this->CreateAGAObject(); } void AGALittleArrowsMA::InstallNotificationRoutine(AGANotifyMAPtr notificationRoutine, void* userData) { // Save the notification routine fn pointer and user data // for notification handling. mNotificationRoutine = notificationRoutine; mUserData = userData; } void AGALittleArrowsMA::HandleNotification(SInt32 deltaValue) { // Update the linked TNumberText, if any, call the // installed notification function, and propagate our // event number. if (mLinkedNumberText != NULL) mLinkedNumberText->SetValue(mLinkedNumberText->GetValue() + deltaValue, kRedraw); if (mNotificationRoutine != NULL) (*mNotificationRoutine)(this, deltaValue, mUserData); this->HandleEvent(fEventNumber, this, NULL); (void) this->Focus(); } void AGALittleArrowsMA::DoPostCreate(TDocument* itsDocument) { // Create and set up the AGAObject. Inherited::DoPostCreate(itsDocument); this->CreateAGAObject(); } void AGALittleArrowsMA::CreateAGAObject() { // Instantiate the particular AGAObject subclass. VRect viewRect(0, 0, fSize.h, fSize.v); CRect bounds; this->ViewToQDRect(viewRect, bounds); FailNIL(mAGAObject = new AGALittleArrows(bounds)); mAGAObject->InstallNotificationRoutine(AGALittleArrowsMA::RealAGANotifier, this); if (fDimmed || ! fEnabled) mAGAObject->SetEnable(AGAObject::kDisabled, AGAObject::kDontRedraw); if (fUserArea != 0) { mLinkedNumberText = (TNumberText*) this->GetWindow()->FindSubView(fUserArea); if (mLinkedNumberText != NULL) if (! MA_MEMBER(mLinkedNumberText, TNumberText)) mLinkedNumberText = NULL; } } void AGALittleArrowsMA::Draw(const VRect& /*area*/) { // Let the AGAObject draw itself. if (mAGAObject != NULL) mAGAObject->DrawObject(); } void AGALittleArrowsMA::SetFrame(const VRect& newFrame, Boolean invalidate) { // Let the MacApp and AGA objects update their locations. Inherited::SetFrame(newFrame, invalidate); SetAGAObjectFrame(this, mAGAObject, newFrame, invalidate); } void AGALittleArrowsMA::DoMouseCommand(VPoint& theMouse, TToolboxEvent* /*event*/, CPoint /*hysteresis*/) { // Let the AGAObject track the mouse; if tracking succeeds // handle our event number. if (mAGAObject->TrackMouse(this->ViewToQDPt(theMouse))) this->HandleEvent(fEventNumber, this, NULL); } void AGALittleArrowsMA::DimState(Boolean state, Boolean redraw) { // Set the AGAObject's enable state. fDimmed = state; if (mAGAObject != NULL) { Boolean wantRedraw = redraw && this->Focus() && this->IsVisible(); mAGAObject->SetEnable(!state, wantRedraw); } } void AGALittleArrowsMA::Dim() { // Set the AGAObject's enable state, with immediate redraw. if (mAGAObject != NULL) mAGAObject->SetEnable(AGAObject::kDisabled, this->Focus() && this->IsVisible()); } void AGALittleArrowsMA::SetEnable(Boolean state) { Inherited::SetEnable(state); // Set the AGAObject's enable state, without redraw. if (mAGAObject != NULL) mAGAObject->SetEnable(state, AGAObject::kDontRedraw); } void AGALittleArrowsMA::RealAGANotifier(AGALittleArrows* /*theAGAObject*/, SInt32 deltaValue, void* userData) { // This is a static function. Cast the user data to get // the AGAScrollerScrollBarMA object, have it handle the notification. ((AGALittleArrowsMA*) userData)->HandleNotification(deltaValue); } // // AGADisclosureTriangleMA ---------------------------------------------------- // #undef Inherited #define Inherited TControl MA_DEFINE_CLASS_M1(AGADisclosureTriangleMA, Inherited); AGADisclosureTriangleMA::AGADisclosureTriangleMA() { mAGAObject = NULL; } AGADisclosureTriangleMA::~AGADisclosureTriangleMA() { // Delete AGA object if we successfully allocated it. if (mAGAObject != NULL) delete mAGAObject; } void AGADisclosureTriangleMA::IAGADisclosureTriangleMA(TView* itsSuperView, const VPoint& itsLocation, const VPoint& itsSize, SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, const TextStyle& itsTextStyle) { this->IControl(itsSuperView, itsLocation, itsSize, itsHSizeDet, itsVSizeDet, itsTextStyle); this->CreateAGAObject(); } void AGADisclosureTriangleMA::DoPostCreate(TDocument* itsDocument) { // Create and set up the AGAObject. Inherited::DoPostCreate(itsDocument); this->CreateAGAObject(); } void AGADisclosureTriangleMA::CreateAGAObject() { // Instantiate the particular AGAObject subclass. VRect viewRect(0, 0, fSize.h, fSize.v); CRect bounds; this->ViewToQDRect(viewRect, bounds); FailNIL(mAGAObject = new AGADisclosureTriangle(bounds, AGAObject::kAutomaticState)); if (fDimmed || ! fEnabled) mAGAObject->SetEnable(AGAObject::kDisabled, AGAObject::kDontRedraw); // Disclosure triangle has to erase when animating, so make sure that // it doesn't assume we're on a gray background. this->Focus(); InstallAGABackgroundColors(mAGAObject, kInstallOnlyIfCustom); } void AGADisclosureTriangleMA::Draw(const VRect& /*area*/) { // Let the AGAObject draw itself. if (mAGAObject != NULL) mAGAObject->DrawObject(); } void AGADisclosureTriangleMA::SetFrame(const VRect& newFrame, Boolean invalidate) { // Let the MacApp and AGA objects update their locations. Inherited::SetFrame(newFrame, invalidate); SetAGAObjectFrame(this, mAGAObject, newFrame, invalidate); } void AGADisclosureTriangleMA::DoMouseCommand(VPoint& theMouse, TToolboxEvent* /*event*/, CPoint /*hysteresis*/) { // Let the AGAObject track the mouse; if tracking succeeds // handle our event number. if (mAGAObject->TrackMouse(this->ViewToQDPt(theMouse))) this->HandleEvent(fEventNumber, this, NULL); } void AGADisclosureTriangleMA::DimState(Boolean state, Boolean redraw) { // Set the AGAObject's enable state. fDimmed = state; if (mAGAObject != NULL) { Boolean wantRedraw = redraw && this->Focus() && this->IsVisible(); mAGAObject->SetEnable(!state, wantRedraw); } } void AGADisclosureTriangleMA::Dim() { // Set the AGAObject's enable state, with immediate redraw. if (mAGAObject != NULL) mAGAObject->SetEnable(AGAObject::kDisabled, this->Focus() && this->IsVisible()); } void AGADisclosureTriangleMA::SetEnable(Boolean state) { Inherited::SetEnable(state); // Set the AGAObject's enable state, without redraw. if (mAGAObject != NULL) mAGAObject->SetEnable(state, AGAObject::kDontRedraw); } // // AGAProgressIndicatorMA ---------------------------------------------------- // #undef Inherited #define Inherited TControl MA_DEFINE_CLASS_M1(AGAProgressIndicatorMA, Inherited); AGAProgressIndicatorMA::AGAProgressIndicatorMA() { mAGAObject = NULL; } AGAProgressIndicatorMA::~AGAProgressIndicatorMA() { // Delete AGA object if we successfully allocated it. this->StopAutoAnimate(); if (mAGAObject != NULL) delete mAGAObject; } void AGAProgressIndicatorMA::IAGAProgressIndicatorMA(TView* itsSuperView, const VPoint& itsLocation, const VPoint& itsSize, SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, const TextStyle& itsTextStyle) { this->IControl(itsSuperView, itsLocation, itsSize, itsHSizeDet, itsVSizeDet, itsTextStyle); this->CreateAGAObject(); } void AGAProgressIndicatorMA::DoPostCreate(TDocument* itsDocument) { // Create and set up the AGAObject. Inherited::DoPostCreate(itsDocument); this->CreateAGAObject(); } void AGAProgressIndicatorMA::CreateAGAObject() { // Instantiate the particular AGAObject subclass. VRect viewRect(0, 0, fSize.h, fSize.v); CRect bounds; this->ViewToQDRect(viewRect, bounds); FailNIL(mAGAObject = new AGAProgressIndicator(bounds, 0, 100)); if (fDimmed || ! fEnabled) mAGAObject->SetEnable(AGAObject::kDisabled, AGAObject::kDontRedraw); if (fUserArea != 0) this->StartAutoAnimate(); } void AGAProgressIndicatorMA::Draw(const VRect& /*area*/) { // Let the AGAObject draw itself. if (mAGAObject != NULL) mAGAObject->DrawObject(); } void AGAProgressIndicatorMA::SetFrame(const VRect& newFrame, Boolean invalidate) { // Let the MacApp and AGA objects update their locations. Inherited::SetFrame(newFrame, invalidate); SetAGAObjectFrame(this, mAGAObject, newFrame, invalidate); } Boolean AGAProgressIndicatorMA::DoIdle(IdlePhase phase) { // Let the AGAObject do one animation step. if ((phase == idleContinue) && (mAGAObject != NULL) && this->Focus()) mAGAObject->QuantizedAnimate(); return false; // did not free self } void AGAProgressIndicatorMA::StartAutoAnimate() { // Place ourself on the cohandler chain so we'll get idle time. fNextHandler = NULL; // if we still point our superview, the two chains will be confused this->SetIdleFreq(0); // idle often this->SetEnable(true); // we won't get idle time if we're disabled! gApplication->InstallCohandler(this, true); } void AGAProgressIndicatorMA::StopAutoAnimate() { // Remove ourself on the cohandler chain so we don't get idle time. gApplication->InstallCohandler(this, false); } // // AGASeparatorMA ---------------------------------------------------- // #undef Inherited #define Inherited TView MA_DEFINE_CLASS_M1(AGASeparatorMA, Inherited); AGASeparatorMA::AGASeparatorMA() { mAGAObject = NULL; } AGASeparatorMA::~AGASeparatorMA() { // Delete AGA object if we successfully allocated it. if (mAGAObject != NULL) delete mAGAObject; } void AGASeparatorMA::IAGASeparatorMA(TDocument* itsDocument, TView* itsSuperView, const VPoint& itsLocation, const VPoint& itsSize, SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet) { this->IView(itsDocument, itsSuperView, itsLocation, itsSize, itsHSizeDet, itsVSizeDet); this->CreateAGAObject(); } void AGASeparatorMA::DoPostCreate(TDocument* itsDocument) { // Create and set up the AGAObject. Inherited::DoPostCreate(itsDocument); this->CreateAGAObject(); } void AGASeparatorMA::CreateAGAObject() { // Instantiate the particular AGAObject subclass. VRect viewRect(0, 0, fSize.h, fSize.v); CRect bounds; this->ViewToQDRect(viewRect, bounds); FailNIL(mAGAObject = new AGASeparator(bounds)); } void AGASeparatorMA::Draw(const VRect& /*area*/) { // Let the AGAObject draw itself. if (mAGAObject != NULL) mAGAObject->DrawObject(); } void AGASeparatorMA::SetFrame(const VRect& newFrame, Boolean invalidate) { // Let the MacApp and AGA objects update their locations. Inherited::SetFrame(newFrame, invalidate); SetAGAObjectFrame(this, mAGAObject, newFrame, invalidate); } // // AGATargetBorderViewMA ---------------------------------------------------- // #undef Inherited #define Inherited TTargetBorderView MA_DEFINE_CLASS_M1(AGATargetBorderViewMA, Inherited); void AGATargetBorderViewMA::IAGATargetBorderViewMA(TDocument* itsDocument, TView* itsSuperView, const VPoint& itsLocation, const VPoint& itsSize, SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, IDType itsTargetView) { this->ITargetBorderView(itsDocument, itsSuperView, itsLocation, itsSize, itsHSizeDet, itsVSizeDet, itsTargetView); } void AGATargetBorderViewMA::DoPostCreate(TDocument* itsDocument) { // Save the background colors we will need to erase. Inherited::DoPostCreate(itsDocument); this->Focus(); if (! DetermineAGABackgroundColors(&mEnabledBackgroundColor, &mDisabledBackgroundColor, kInstallOnlyIfCustom)) { mEnabledBackgroundColor = gAGARamp[r2]; mDisabledBackgroundColor = gAGARamp[r2]; } } void AGATargetBorderViewMA::Draw(const VRect& /*area*/) { // Set the color, always draw. TTargetBorderView leaves // background unerased in 1-bit. AGADrawingEnvironment env; GDIterator iter; Boolean deep; Boolean isTarget = this->ContainsTarget(gApplication->GetTarget()); Boolean enabled = this->IsEnabled(); CTemporaryRegion borderRegion; while (iter.More(deep)) { if (deep) { if (isTarget && enabled) ::RGBForeColor(&gAGARamp[r8]); else if (enabled) ::RGBForeColor(&mEnabledBackgroundColor); else ::RGBForeColor(&mDisabledBackgroundColor); } else { if (isTarget && enabled) ::RGBForeColor(&gAGARamp[rB]); else ::RGBForeColor(&gAGARamp[rW]); } this->ComputeBorderRegion(borderRegion); PaintRgn(borderRegion); } } void AGATargetBorderViewMA::ComputeBorderRegion(RgnHandle borderRegion) { // Return the border region to be painted or invalidated. CRect qdArea; this->GetQDExtent(qdArea); AGAComputeTargetBorderRegion(borderRegion, qdArea, false /*isNotched*/); } // // AGANotchedTargetBorderViewMA ---------------------------------------------------- // #undef Inherited #define Inherited AGATargetBorderViewMA MA_DEFINE_CLASS_M1(AGANotchedTargetBorderViewMA, Inherited); void AGANotchedTargetBorderViewMA::IAGANotchedTargetBorderViewMA(TDocument* itsDocument, TView* itsSuperView, const VPoint& itsLocation, const VPoint& itsSize, SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, IDType itsTargetView) { this->IAGATargetBorderViewMA(itsDocument, itsSuperView, itsLocation, itsSize, itsHSizeDet, itsVSizeDet, itsTargetView); } void AGANotchedTargetBorderViewMA::ComputeBorderRegion(RgnHandle borderRegion) { // Return the border region to be painted or invalidated. CRect qdArea; this->GetQDExtent(qdArea); AGAComputeTargetBorderRegion(borderRegion, qdArea, true /*isNotched*/); } // // AGATargetBorderFrameViewMA ---------------------------------------------------- // #undef Inherited #define Inherited AGATargetBorderViewMA MA_DEFINE_CLASS_M1(AGATargetBorderFrameViewMA, Inherited); void AGATargetBorderFrameViewMA::IAGATargetBorderFrameViewMA(TDocument* itsDocument, TView* itsSuperView, const VPoint& itsLocation, const VPoint& itsSize, SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, IDType itsTargetView) { this->IAGATargetBorderViewMA(itsDocument, itsSuperView, itsLocation, itsSize, itsHSizeDet, itsVSizeDet, itsTargetView); } void AGATargetBorderFrameViewMA::Draw(const VRect& area) { // Let the AGATargetBorderViewMA draw the target border, // then draw the "3D" sunken frame portion.. Inherited::Draw(area); CRect qdArea; this->GetQDExtent(qdArea); ::InsetRect(qdArea, 3, 3); AGADrawBorderFrame(qdArea, this->IsEnabled(), false /*isNotched*/, true /*drawFrame*/, &gAGARamp[r2]); ::RGBForeColor(&gAGARamp[rB]); ::RGBBackColor(&gAGARamp[rW]); } void AGATargetBorderFrameViewMA::Dim() { // Suppress patBic painting over our frame. } void AGATargetBorderFrameViewMA::SetEnable(Boolean state) { // Redraw now; unlike TControl, TView does not automatically // redraw when you disable/dim it. Inherited::SetEnable(state); if (this->Focus() && this->IsVisible()) { VRect extent; this->GetExtent(extent); this->Draw(extent); } } // // AGANotchedTargetBorderFrameViewMA ---------------------------------------------------- // #undef Inherited #define Inherited AGATargetBorderViewMA MA_DEFINE_CLASS_M1(AGANotchedTargetBorderFrameViewMA, Inherited); void AGANotchedTargetBorderFrameViewMA::IAGANotchedTargetBorderFrameViewMA(TDocument* itsDocument, TView* itsSuperView, const VPoint& itsLocation, const VPoint& itsSize, SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, IDType itsTargetView) { this->IAGATargetBorderViewMA(itsDocument, itsSuperView, itsLocation, itsSize, itsHSizeDet, itsVSizeDet, itsTargetView); } void AGANotchedTargetBorderFrameViewMA::Draw(const VRect& area) { // Let the AGATargetBorderViewMA draw the target border, // then draw the "3D" sunken frame portion.. Inherited::Draw(area); CRect qdArea; this->GetQDExtent(qdArea); ::InsetRect(qdArea, 3, 3); AGADrawBorderFrame(qdArea, this->IsEnabled(), true /*isNotched*/, true /*drawFrame*/, &gAGARamp[r2]); ::RGBForeColor(&gAGARamp[rB]); ::RGBBackColor(&gAGARamp[rW]); } void AGANotchedTargetBorderFrameViewMA::Dim() { // Suppress patBic painting over our frame. } void AGANotchedTargetBorderFrameViewMA::ComputeBorderRegion(RgnHandle borderRegion) { // Return the border region to be painted or invalidated. CRect qdArea; this->GetQDExtent(qdArea); AGAComputeTargetBorderRegion(borderRegion, qdArea, true /*isNotched*/); } // // AGAGroupBoxMA ---------------------------------------------------- // #undef Inherited #define Inherited TCluster MA_DEFINE_CLASS_M1(AGAGroupBoxMA, Inherited); AGAGroupBoxMA::AGAGroupBoxMA() { mAGAObject = NULL; mIsPrimaryType = true; } AGAGroupBoxMA::~AGAGroupBoxMA() { // Delete AGA object if we successfully allocated it. if (mAGAObject != NULL) delete mAGAObject; } void AGAGroupBoxMA::IAGAGroupBoxMA(TView* itsSuperView, const VPoint& itsLocation, const VPoint& itsSize, SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, ResNumber itsRsrcID, short itsIndex) { this->ICluster(itsSuperView, itsLocation, itsSize, itsHSizeDet, itsVSizeDet, itsRsrcID, itsIndex); this->CreateAGAObject(); } void AGAGroupBoxMA::DoPostCreate(TDocument* itsDocument) { // Create and set up the AGAObject. Inherited::DoPostCreate(itsDocument); this->CreateAGAObject(); } void AGAGroupBoxMA::CreateAGAObject() { // Instantiate the particular AGAObject subclass. CStr255 label; VRect viewRect(0, 0, fSize.h, fSize.v); CRect bounds; this->ViewToQDRect(viewRect, bounds); this->GetLabel(label); FailNIL(mAGAObject = new AGAGroupBox(bounds, AGATextStyle(fTextStyle), mIsPrimaryType, label)); if ((fUserArea != 0) && (fSuperView != NULL)) { TView* gapView = fSuperView->FindSubView(fUserArea); if (gapView != NULL) { CRect gapExtent; gapView->GetQDExtent(gapExtent); mAGAObject->SetTitleGap(5 + gapExtent.GetLength(hSel)); } } // Note that unlike other controls, for group boxes, we allow // "disabled" text to draw normal. This is because group box // views typically are "disabled" but not "dimmed". if (fDimmed) mAGAObject->SetEnable(AGAObject::kDisabled, AGAObject::kDontRedraw); } void AGAGroupBoxMA::Draw(const VRect& /*area*/) { // Let the AGAObject draw itself. if (mAGAObject != NULL) mAGAObject->DrawObject(); } void AGAGroupBoxMA::SetFrame(const VRect& newFrame, Boolean invalidate) { // Let the MacApp and AGA objects update their locations. Inherited::SetFrame(newFrame, invalidate); SetAGAObjectFrame(this, mAGAObject, newFrame, invalidate); } void AGAGroupBoxMA::DoMouseCommand(VPoint& /*theMouse*/, TToolboxEvent* /*event*/, CPoint /*hysteresis*/) { // Group box drawing is based on enable state, but we don't // want clicking on the group box itself to cause highlighting. } void AGAGroupBoxMA::DimState(Boolean state, Boolean redraw) { // Set the AGAObject's enable state. fDimmed = state; if (mAGAObject != NULL) { Boolean wantRedraw = redraw && this->Focus() && this->IsVisible(); mAGAObject->SetEnable(!state, wantRedraw); } } void AGAGroupBoxMA::Dim() { // Set the AGAObject's enable state, with immediate redraw. if (mAGAObject != NULL) mAGAObject->SetEnable(AGAObject::kDisabled, this->Focus() && this->IsVisible()); } void AGAGroupBoxMA::SetLabel(const CStr255& theLabel, Boolean redraw) { // Change the current text in TCluster and in // the AGA object. Let TCluster use the redraw // to invalidate as usual. Inherited::SetLabel(theLabel, redraw); if (mAGAObject != NULL) { Str255 textString; AGA_PLstrcpy(textString, theLabel); mAGAObject->SetTitle(textString, AGAObject::kDontRedraw); } } // // AGASecondaryGroupBoxMA ---------------------------------------------------- // #undef Inherited #define Inherited AGAGroupBoxMA MA_DEFINE_CLASS_M1(AGASecondaryGroupBoxMA, Inherited); AGASecondaryGroupBoxMA::AGASecondaryGroupBoxMA() { mIsPrimaryType = false; } AGASecondaryGroupBoxMA::~AGASecondaryGroupBoxMA() { } void AGASecondaryGroupBoxMA::IAGASecondaryGroupBoxMA(TView* itsSuperView, const VPoint& itsLocation, const VPoint& itsSize, SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, ResNumber itsRsrcID, short itsIndex) { this->IAGAGroupBoxMA(itsSuperView, itsLocation, itsSize, itsHSizeDet, itsVSizeDet, itsRsrcID, itsIndex); } // // AGATabPanelMA ---------------------------------------------------- // #undef Inherited #define Inherited TControl MA_DEFINE_CLASS_M1(AGATabPanelMA, Inherited); AGATabPanelMA::AGATabPanelMA() { mAGAObject = NULL; mPanelContainerView = NULL; mActivePanelView = NULL; } AGATabPanelMA::~AGATabPanelMA() { // Delete AGA object if we successfully allocated it. // We also need to make sure that all panel views not currently // installed get destructed. if (mAGAObject != NULL) { SInt32 numTabs; numTabs = mAGAObject->GetNumTabs(); for (SInt32 tabIndex = 0; tabIndex < numTabs; tabIndex++) { if (tabIndex != mAGAObject->GetCurrentTab()) { TView* aPanelView = (TView*) mAGAObject->GetTabUserData(tabIndex); (void) FreeIfObject(aPanelView); } } delete mAGAObject; } } void AGATabPanelMA::IAGATabPanelMA(TView* itsSuperView, const VPoint& itsLocation, const VPoint& itsSize, SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, const TextStyle& itsTextStyle) { this->IControl(itsSuperView, itsLocation, itsSize, itsHSizeDet, itsVSizeDet, itsTextStyle); this->CreateAGAObject(); // Create the container view that we'll load panels in and out of. this->CreateContainerView(); } void AGATabPanelMA::DoPostCreate(TDocument* itsDocument) { // Create and set up the AGAObject. Inherited::DoPostCreate(itsDocument); this->CreateAGAObject(); // Create the container view that we'll load panels in and out of. this->CreateContainerView(); } void AGATabPanelMA::CreateAGAObject() { // Instantiate the particular AGAObject subclass. VRect viewRect(0, 0, fSize.h, fSize.v); CRect bounds; this->ViewToQDRect(viewRect, bounds); FailNIL(mAGAObject = new AGATabPanel(bounds, 0, AGATextStyle(fTextStyle), fUserArea)); if (fDimmed || ! fEnabled) mAGAObject->SetEnable(AGAObject::kDisabled, AGAObject::kDontRedraw); // Tabs have to erase when drawing, so make sure that // it doesn't assume we're on a gray background. this->Focus(); InstallAGABackgroundColors(mAGAObject, kInstallOnlyIfCustom); } void AGATabPanelMA::CreateContainerView() { if (mAGAObject->HasFrame()) // if no frame, we just run the tabs, not the panels { // Create a subview to contain the panels that we load and unload. // We locate it 3 pixels inset from our the frame content area. VCoordinate tabHeight = mAGAObject->GetTabHeight(); VPoint viewLocation(3, 3 + tabHeight); VPoint viewSize(fSize.h - 6, fSize.v - tabHeight - 6); mPanelContainerView = new TView; mPanelContainerView->IView(fDocument, this, viewLocation, viewSize, fSizeDeterminer[hSel], fSizeDeterminer[vSel]); } } void AGATabPanelMA::Draw(const VRect& /*area*/) { // Let the AGAObject draw itself. if (mAGAObject != NULL) mAGAObject->DrawObject(); // Set the background color so that any non-AGA subviews // that erase their background without assuming a color // will use our current tab panel color. if (this->IsEnabled()) ::RGBBackColor(&gAGARamp[r1]); else ::RGBBackColor(&gAGARamp[r2]); } void AGATabPanelMA::SetFrame(const VRect& newFrame, Boolean invalidate) { // Let the MacApp and AGA objects update their locations. (void) this->Focus(); CRect frame; this->GetQDExtent(frame); ::InvalRect(frame); Inherited::SetFrame(newFrame, invalidate); SetAGAObjectFrame(this, mAGAObject, newFrame, invalidate); } void AGATabPanelMA::DoMouseCommand(VPoint& theMouse, TToolboxEvent* /*event*/, CPoint /*hysteresis*/) { // Let the AGAObject track the mouse; if tracking succeeds // handle our event number. if (mAGAObject->TrackMouse(this->ViewToQDPt(theMouse))) this->HandleTabSwitch(mAGAObject->GetLastTabClicked()); } void AGATabPanelMA::DimState(Boolean state, Boolean redraw) { // Set the AGAObject's enable state. fDimmed = state; if (mAGAObject != NULL) { Boolean wantRedraw = redraw && this->Focus() && this->IsVisible(); mAGAObject->SetEnable(!state, wantRedraw); } this->SetSubviewsEnable(! state); } void AGATabPanelMA::Dim() { // Set the AGAObject's enable state, with immediate redraw. if (mAGAObject != NULL) mAGAObject->SetEnable(AGAObject::kDisabled, this->Focus() && this->IsVisible()); } void AGATabPanelMA::SetEnable(Boolean state) { Inherited::SetEnable(state); // Set the AGAObject's enable state, without redraw. if (mAGAObject != NULL) mAGAObject->SetEnable(state, AGAObject::kDontRedraw); this->SetSubviewsEnable(state); } void AGATabPanelMA::SwitchPanels(SInt32 newTabIndex) { // Switch to the specified tab index. if (mAGAObject != NULL) mAGAObject->SetCurrentTab(newTabIndex, this->Focus()); this->SwitchPanelIn(newTabIndex, this->SwitchPanelOut()); } void AGATabPanelMA::HandleTabSwitch(SInt32 newTabIndex) { // If it's OK to switch tabs (may need to validate current // panel before switching), do the switch. if (this->ValidatePanel(mAGAObject->GetCurrentTab())) { this->SwitchPanels(newTabIndex); this->HandleEvent(fEventNumber, this, NULL); } } void AGATabPanelMA::AddPanel(SInt16 panelResourceID, StringPtr tabLabel) { // Create another tab and then install the specified View resource // onto that tab. if (mAGAObject != NULL) { Str255 actualTabLabel; SInt32 numTabs; if (tabLabel != NULL) AGA_PLstrcpy(actualTabLabel, tabLabel); else { Handle viewHandle; SInt16 viewID; OSType viewType; FailNIL(viewHandle = ::GetResource('View', panelResourceID)); ::GetResInfo(viewHandle, &viewID, &viewType, actualTabLabel); // Don't release it -- we're about to cause it to be read anyway. } numTabs = mAGAObject->GetNumTabs(); mAGAObject->SetNumTabs(numTabs + 1, AGATabPanel::kDontShrink); this->InstallPanel(numTabs, panelResourceID, actualTabLabel); } } void AGATabPanelMA::InstallPanel(SInt32 tabIndex, SInt16 panelResourceID, StringPtr tabLabel) { // Install the specified View resource onto the specified existing tab. if (mAGAObject != NULL) { TView* newPanelView; SInt32 numTabs; numTabs = mAGAObject->GetNumTabs(); if (tabIndex < numTabs) { // Wrap the DoCreateViews with custom color values so that the // AGA objects in the panel hierarchy will get the right background // colors. TurnOnCustomAGABackgroundColors(&gAGARamp[r1], &gAGARamp[r2]); // FailNIL(newPanelView = gViewServer->DoCreateViews(fDocument, NULL, panelResourceID, gZeroVPt)); FailNIL(newPanelView = gViewServer->DoCreateViews(fDocument, mPanelContainerView, panelResourceID, gZeroVPt)); TurnOffCustomAGABackgroundColors(); newPanelView->Show(false, kRedraw); mAGAObject->SetTabUserData(tabIndex, newPanelView); if (tabLabel != NULL) { mAGAObject->SetTabLabel(tabIndex, tabLabel); mAGAObject->CalculateTabWidths(); } // If this panel corresponds to the initial value, switch it in. if (mAGAObject->GetCurrentTab() == tabIndex) this->SwitchPanels(tabIndex); } } } TView* AGATabPanelMA::GetPanelView(SInt32 tabIndex) { // Return the TView* of the specified tab's panel view hierarchy. if (mAGAObject == NULL) return NULL; else return (TView*) mAGAObject->GetTabUserData(tabIndex); } void AGATabPanelMA::SetSubviewsEnable(Boolean state) { // Do a recursive walk of our panel subviews, setting the // enable state of all of its subviews. if (mPanelContainerView != NULL) { this->DoSubviewsEnable(mPanelContainerView, state); mPanelContainerView->ForceRedraw(); } } void AGATabPanelMA::DoSubviewsEnable(TView* aSuperView, Boolean state) { // Do a recursive walk of our panel subviews, setting the // enable state of all of its subviews. CSubViewIterator iter(aSuperView); for (TView* aSubView = iter.FirstSubView(); iter.More(); aSubView = iter.NextSubView()) { aSubView->SetEnable(state); if (MA_MEMBER(aSubView, TControl)) ((TControl*) aSubView)->DimState(! state, kDontRedraw); this->DoSubviewsEnable(aSubView, state); } } Boolean AGATabPanelMA::ValidatePanel(SInt32 /*currentTabIndex*/) { // (Override for app-specific validation.) // // Return true if the current (specified) panel is valid and // it's OK to switch to a different panel. Return false otherwise // and the tab switch will not occur; it's OK to alert the user // of the invalid data before returning. // return true; } Boolean AGATabPanelMA::SwitchPanelOut() { // Yank the current panel view hierarchy out of the container view. Boolean panelContainedTarget = false; if (mActivePanelView != NULL) { TEventHandler* currentTarget = gApplication->GetTarget(); if (currentTarget != NULL) if (MA_MEMBER(currentTarget, TView)) if (mActivePanelView->ContainsSubView((TView*) currentTarget)) { panelContainedTarget = true; (void) currentTarget->ResignTarget(); } mActivePanelView->Show(false, kRedraw); //mPanelContainerView->RemoveSubView(mActivePanelView); mActivePanelView = NULL; } return panelContainedTarget; } void AGATabPanelMA::SwitchPanelIn(SInt32 newTabIndex, Boolean targetInPanel) { // Switch the specified panel view hierarchy in buy placing it // inside the container view. if (mAGAObject != NULL) { TView* newPanelView = (TView*) mAGAObject->GetTabUserData(newTabIndex); if (newPanelView != NULL) { mActivePanelView = newPanelView; // // Before redrawing, center the new panel inside the container. // /* VRect containerFrame; VPoint containerSize; VRect panelFrame; VPoint panelSize; VPoint leftoverSize; mPanelContainerView->GetFrame(containerFrame); containerSize = containerFrame.GetSize(); newPanelView->GetFrame(panelFrame); panelSize = panelFrame.GetSize(); leftoverSize.h = containerSize.h - panelSize.h; leftoverSize.v = containerSize.v - panelSize.v; panelFrame.left = leftoverSize.h / 2; panelFrame.top = leftoverSize.v / 2; panelFrame.right = panelFrame.left + panelSize.h; panelFrame.bottom = panelFrame.top + panelSize.v; // // Install the panel as a subpane of the container, // then make it visible. // mPanelContainerView->AddSubView(newPanelView); newPanelView->SetFrame(panelFrame, kInvalidate); */ newPanelView->Show(true, kRedraw); if (targetInPanel) { TView* wannabeTarget = newPanelView->FindTarget(); if (wannabeTarget != NULL) { (void) wannabeTarget->BecomeTarget(); if (MA_MEMBER(wannabeTarget, TEditText)) ((TEditText*) wannabeTarget)->SetTargetSelection(kRedraw); } } } } } // // AGASmallTabPanelMA ---------------------------------------------------- // #undef Inherited #define Inherited AGATabPanelMA MA_DEFINE_CLASS_M1(AGASmallTabPanelMA, Inherited); AGASmallTabPanelMA::AGASmallTabPanelMA() { } AGASmallTabPanelMA::~AGASmallTabPanelMA() { } void AGASmallTabPanelMA::IAGASmallTabPanelMA(TView* itsSuperView, const VPoint& itsLocation, const VPoint& itsSize, SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, const TextStyle& itsTextStyle) { this->IAGATabPanelMA(itsSuperView, itsLocation, itsSize, itsHSizeDet, itsVSizeDet, itsTextStyle); } void AGASmallTabPanelMA::CreateAGAObject() { Inherited::CreateAGAObject(); // Set the tabs to use the standard small appearance. mAGAObject->SetTabSize(AGATabPanel::kSmallTabs); mAGAObject->SetLabelsStyle(gAGAStdBoldSmallStyle); }